package com.web.mall.controller;

import com.web.mall.document.EsGoods;
import com.web.mall.service.EsGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin("*")
public class EsGoodsController {
    @Autowired
    private EsGoodsService esGoodsService;


    @GetMapping("/queryItemDetail")
    public EsGoods queryItemDetail( Long goods_id){
        return esGoodsService.findEsItemById(goods_id);
    }

    @GetMapping("/queryItemByKeyword")
    public List<EsGoods> queryItemByKeyword( String key){
        Page<EsGoods> page = esGoodsService.queryEsItemByKey(key, null);
//        System.out.println(page);
        return page.getContent();
    }
}
